﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using A2DFramework.AOPService.Configuration;
using System.Reflection;

namespace A2DFramework.AOPService.Core
{
    public static class AOPProcessorLoader
    {
        public static List<IAOPProcessor> GetProcessors()
        {
            List<IAOPProcessor> lst = new List<IAOPProcessor>();
            foreach(var processorImplClassName in AOPServiceConfiguration.Processors)
            {
                Type type = Type.GetType(processorImplClassName);
                if (type == null)
                {
                    Console.WriteLine("{0} null", type.FullName);
                    continue;
                }
                IAOPProcessor processor = Activator.CreateInstance(type) as IAOPProcessor;
                if (processor == null)
                {
                    Console.WriteLine("Activator.CreateInstance({0}) null", type.FullName);
                    continue;
                }
                lst.Add(processor);
            }

            return lst;
        }
    }
}
